﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Ajax.Samples;
using System.ServiceModel.Channels;
using System.ServiceModel.Web;
using System.ServiceModel.Description;
using MBWebService.Core.Interfaces;
using System.ServiceModel;
using MBWebService.Core.Classes;
using MBWebService.Core;

namespace MBWebService.DevServer
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    [ServiceKnownType(typeof(MetadataItem))]
    [ServiceKnownType(typeof(BasicCollectionItem))]
    public class MBService : IMediaBrowserService
    {
        WebServiceHost host;

        public void StartService()
        {
            this.host = new WebServiceHost(this, AppSettings.Address);
            
            WebHttpBinding binding = new WebHttpBinding
            {
                CrossDomainScriptAccessEnabled = true
            };

            var behaviour = new WebHttpBehavior
            {
                HelpEnabled = true,
                FaultExceptionEnabled = true
            };

            this.host.AddServiceEndpoint(typeof(IMediaBrowserService), binding, string.Empty)
                .Behaviors.Add(behaviour);

            this.host.Open();
        }

        #region IMediaBrowserService Members

        public Core.Classes.BasicItem GetItem(Guid id)
        {
            throw new NotImplementedException();
        }

        public Core.Classes.BasicCollectionItem GetStartUpFolders()
        {
            throw new NotImplementedException();
        }

        public Core.Classes.BasicCollectionItem GetCollection(Guid id)
        {
            throw new NotImplementedException();
        }

        public Core.Classes.MetadataItem GetMetadata(Guid id)
        {
            throw new NotImplementedException();
        }

        public string getStreamItems(Guid id)
        {
            throw new NotImplementedException();
        }

        public bool StreamItem(Guid id, string fname, string url)
        {
            throw new NotImplementedException();
        }

        public Core.Classes.PictureItem GetImage(Guid id, Core.Enums.ImageTypes imageType, int maxHeight, int maxWidth)
        {
            throw new NotImplementedException();
        }

        public Core.Classes.TrailerInfo[] GetTrailers(Guid id)
        {
            throw new NotImplementedException();
        }

        public Core.Classes.PlaybackDevice[] GetAttachedDevices()
        {
            throw new NotImplementedException();
        }

        public BasicCollectionItem GetRecentlyAdded(Guid id)
        {
            throw new NotImplementedException();
        }

        public BasicCollectionItem GetRecentlyWatched(Guid id)
        {
            throw new NotImplementedException();
        }

        public bool PlayItem(Guid id, string player, bool queue)
        {
            throw new NotImplementedException();
        }

        public Core.Classes.NowPlayingItem GetNowPlaying(bool waitForUpdate, string player)
        {
            throw new NotImplementedException();
        }

        public void SendCommand(Core.Enums.CommandTypes command, string player)
        {
            throw new NotImplementedException();
        }

        public void Seek(int seconds, string player)
        {
            throw new NotImplementedException();
        }

        public void GoToScreen(Core.Enums.ScreenType screenType, string extraInfo, string player)
        {
            throw new NotImplementedException();
        }

        public void PlayTrailer(Core.Classes.TrailerInfo trailer, string player)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
